package com.tcfvic.client.panels;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.VerticalSplitPanel;
import com.tcfvic.client.PersonDetailsListService;
import com.tcfvic.client.PersonDetailsListServiceAsync;
import com.tcfvic.client.panels.widgets.PersonDetailsInputWidget;
import com.tcfvic.client.panels.widgets.PersonDetailsListWidget;

public class PersonDetailsForm {

	/**
	 * Create a remote service proxy to talk to the server-side PersonDetails
	 * service.
	 */
	private final PersonDetailsListServiceAsync personDetailsListService = GWT
			.create(PersonDetailsListService.class);
	private VerticalSplitPanel vSplit = new VerticalSplitPanel();

	public PersonDetailsForm(boolean editing) {
		// Create a Vertical Split Panel
		vSplit = new VerticalSplitPanel();
		vSplit.ensureDebugId("cwVerticalSplitPanel");
		vSplit.setSize("900px", "800px");
		vSplit.setSplitPosition("1%");

		PersonDetailsInputWidget personDetails = new PersonDetailsInputWidget(this);
		PersonDetailsListWidget personListWidget = null;
		if (editing) {
			personListWidget = new PersonDetailsListWidget(
					personDetailsListService, personDetails, this);
			vSplit.setTopWidget(personListWidget);
			vSplit.setSplitPosition("50%");
		}
		personDetails.addPersonList(personListWidget);
		vSplit.setBottomWidget(personDetails);
	}

	public VerticalSplitPanel getvSplit() {
		return vSplit;
	}
}
